<template>
    <div class="container">
        <div class="tabCommonTitle">
            <span>第三方评价证明</span>
        </div>
        <p class="list_title">
            <span class="list_name">鉴定/评审/评价证书</span>
            <a-button class="shangchuan pointer" :class="is_modify=='Y'?'':'disabled'" @click="upload_jdzm" :disabled="is_modify=='Y'?false:true">添加</a-button>
        </p>
        <div class="tableList">
            <table style="text-align:center;" width="1110"  align="center" cellpadding="">
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>评价单位名称</th>
                        <th>上传状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody v-if="jdzmlist.length">
                    <tr v-for="(item, index) in jdzmlist" :key="index">
                        <td>{{index+1}}</td>
                        <td>{{item.jdzsDwmc}}</td>
                        <td>{{item.filePath!='' ?'成功':''}}</td>
                        <td>
                            <!-- <a>
                                <a-icon type="eye" @click="preview_jdzm(item.filePath)"/>
                                <a-icon type="edit" @click="edit_jdzm(item.id)"/>
                                <a-icon type="delete" @click="del_jdzm(item.id)"/>
                            </a> -->
                            <a>
                                <img style="width:18px;height:18px;margin-right:22px;"  @click="preview_jdzm(item.filePath)" src="@/assets/img/yulan.png" alt="">
                                <img v-if="is_modify=='Y'?true:false" style="width:18px;height:18px;margin-right:11px;"  @click="edit_jdzm(item.id)" src="@/assets/img/bianji.png" alt="">
                                <img v-if="is_modify=='Y'?true:false" style="width:18px;height:18px;margin-left:11px;" @click="del_jdzm(item.id)" src="@/assets/img/shanchu1.png" alt="">
                            </a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
      <!--
        <p class="list_title">
            <span class="list_name">评审证书</span>
            <a-button class="shangchuan pointer" :class="is_modify=='Y'?'':'disabled'" @click="upload_pszs" :disabled="is_modify=='Y'?false:true">添加</a-button>
        </p>
        <div class="tableList">
            <table style="text-align:center;" width="1110"  align="center" cellpadding="">
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>评价单位名称</th>
                        <th>上传状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="(item, index) in pszmlist" :key="index">
                        <td>{{index+1}}</td>
                        <td>{{item.pszmDwmc}}</td>
                        <td>{{item.filePath!='' ?'成功':''}}</td>
                        <td>
                        -->
                            <!-- <a>
                                <a-icon type="eye" @click="preview_pszs(item.filePath)"/>
                                <a-icon type="edit" @click="edit_pszs(item.id)"/>
                                <a-icon type="delete" @click="del_pszs(item.id)"/>
                            </a> -->
      <!--
                            <a>
                                <img style="width:18px;height:18px;margin-right:22px;" @click="preview_pszs(item.filePath)" src="@/assets/img/yulan.png" alt="">
                                <img v-if="is_modify=='Y'?true:false" style="width:18px;height:18px;margin-right:11px;" @click="edit_pszs(item.id)" src="@/assets/img/bianji.png" alt="">
                                <img v-if="is_modify=='Y'?true:false" style="width:18px;height:18px;margin-left:11px;" @click="del_pszs(item.id)" src="@/assets/img/shanchu1.png" alt="">
                            </a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
  -->
        <p class="list_title">
            <span class="list_name">第三方验收报告</span>
            <a-button class="shangchuan pointer" :class="is_modify=='Y'?'':'disabled'" @click="upload_ysbg" :disabled="is_modify=='Y'?false:true">添加</a-button>
        </p>
        <div class="tableList">
            <table style="text-align:center;" width="1110"  align="center" cellpadding="">
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>评价单位名称</th>
                        <th>上传状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="(item, index) in ysbglist" :key="index">
                        <td>{{index+1}}</td>
                        <td>{{item.ysbgDwmc}}</td>
                        <td>{{item.filePath!='' ?'成功':''}}</td>
                        <td>
                            <!-- <a>
                                <a-icon type="eye" @click="preview_ysbg(item.filePath)"/>
                                <a-icon type="edit" @click="edit_ysbg(item.id)"/>
                                <a-icon type="delete" @click="del_ysbg(item.id)"/>
                            </a> -->
                            <a>
                                <img style="width:18px;height:18px;margin-right:22px;" @click="preview_ysbg(item.filePath)" src="@/assets/img/yulan.png" alt="">
                                <img v-if="is_modify=='Y'?true:false" style="width:18px;height:18px;margin-right:11px;" @click="edit_ysbg(item.id)" src="@/assets/img/bianji.png" alt="">
                                <img v-if="is_modify=='Y'?true:false" style="width:18px;height:18px;margin-left:11px;" @click="del_ysbg(item.id)" src="@/assets/img/shanchu1.png" alt="">
                            </a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
      <!--
        <p class="list_title">
            <span class="list_name">评价证书</span>
            <a-button class="shangchuan pointer" :class="is_modify=='Y'?'':'disabled'" @click="upload_pjzm" :disabled="is_modify=='Y'?false:true">添加</a-button>
        </p>
        <div class="tableList">
            <table style="text-align:center;" width="1110"  align="center" cellpadding="">
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>评价单位名称</th>
                        <th>上传状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody v-if="pjzmlist.length">
                    <tr v-for="(item, index) in pjzmlist" :key="index">
                        <td>{{index+1}}</td>
                        <td>{{item.pjzmDwmc}}</td>
                        <td>{{item.filePath!='' ?'成功':''}}</td>
                        <td>
                            <a>
                                <img style="width:18px;height:18px;margin-right:22px;"  @click="preview_pjzm(item.filePath)" src="@/assets/img/yulan.png" alt="">
                                <img v-if="is_modify=='Y'?true:false" style="width:18px;height:18px;margin-right:11px;"  @click="edit_pjzm(item.id)" src="@/assets/img/bianji.png" alt="">
                                <img v-if="is_modify=='Y'?true:false" style="width:18px;height:18px;margin-left:11px;" @click="del_pjzm(item.id)" src="@/assets/img/shanchu1.png" alt="">
                            </a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        -->
      <!--
      <p class="list_title">
        <span class="list_name">查新报告</span>
        <a-button class="shangchuan pointer" :class="is_modify=='Y'?'':'disabled'" @click="upload_cxbg" :disabled="is_modify=='Y'?false:true">添加</a-button>
      </p>
      <div class="tableList">
        <table style="text-align:center;" width="1110"  align="center" cellpadding="">
          <thead>
          <tr>
            <th>序号</th>
            <th>评价单位名称</th>
            <th>上传状态</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          <tr v-for="(item, index) in cxbglist" :key="index">
            <td>{{index+1}}</td>
            <td>{{item.cxbgDwmc}}</td>
            <td>{{item.filePath!='' ?'成功':''}}</td>
            <td>
            -->
              <!-- <a>
                  <a-icon type="eye" @click="preview_ysbg(item.filePath)"/>
                  <a-icon type="edit" @click="edit_ysbg(item.id)"/>
                  <a-icon type="delete" @click="del_ysbg(item.id)"/>
              </a> -->
      <!--
              <a>
                <img style="width:18px;height:18px;margin-right:22px;" @click="preview_cxbg(item.filePath)" src="@/assets/img/yulan.png" alt="">
                <img v-if="is_modify=='Y'?true:false" style="width:18px;height:18px;margin-right:11px;" @click="edit_cxbg(item.id)" src="@/assets/img/bianji.png" alt="">
                <img v-if="is_modify=='Y'?true:false" style="width:18px;height:18px;margin-left:11px;" @click="del_cxbg(item.id)" src="@/assets/img/shanchu1.png" alt="">
              </a>
            </td>
          </tr>
          </tbody>
        </table>
      </div>
  -->
      <p class="list_title">
        <span class="list_name">其他评价证明</span>
        <a-button class="shangchuan pointer" :class="is_modify=='Y'?'':'disabled'" @click="upload_qtzm" :disabled="is_modify=='Y'?false:true">添加</a-button>
      </p>
      <div class="tableList">
        <table style="text-align:center;" width="1110"  align="center" cellpadding="">
          <thead>
          <tr>
            <th>序号</th>
            <th>评价单位名称</th>
            <th>上传状态</th>
            <th>评价时间</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          <tr v-for="(item, index) in qtzmlist" :key="index">
            <td>{{index+1}}</td>
            <td>{{item.qtzmDwmc}}</td>
            <td>{{item.filePath!='' ?'成功':''}}</td>
            <td>{{item.qtzmSj || '--'}}</td>
            <td>
              <!-- <a>
                  <a-icon type="eye" @click="preview_ysbg(item.filePath)"/>
                  <a-icon type="edit" @click="edit_ysbg(item.id)"/>
                  <a-icon type="delete" @click="del_ysbg(item.id)"/>
              </a> -->
              <a>
                <img style="width:18px;height:18px;margin-right:22px;" @click="preview_qtzm(item.filePath)" src="@/assets/img/yulan.png" alt="">
                <img v-if="is_modify=='Y'?true:false" style="width:18px;height:18px;margin-right:11px;" @click="edit_qtzm(item.id)" src="@/assets/img/bianji.png" alt="">
                <img v-if="is_modify=='Y'?true:false" style="width:18px;height:18px;margin-left:11px;" @click="del_qtzm(item.id)" src="@/assets/img/shanchu1.png" alt="">
              </a>
            </td>
          </tr>
          </tbody>
        </table>
      </div>
        <a-modal
            v-drag-modal
			:title="modal_title"
            class="enclosure_modal"
			:visible="visible"
            :maskClosable="false"
            :width="500"
            @cancel="handleCancel"
		>
            <template slot="footer">
                <a-button @click="handleCancel">取消</a-button>
                <a-button key="submit" type="primary" :disabled="disabled_add" @click="handleSubmit">保存</a-button>
            </template>
			<a-form-model ref="ruleForm" :model="form" :rules="rules" >
				<!-- <a-form-model-item ref="fujianname" prop="fujianname" label="附件名称：" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }">
					<a-input v-model="form.fujianname" placeholder="附件名称"  @blur="() => {$refs.fujianname.onFieldBlur();}"/>
				</a-form-model-item> -->
                <a-form-model-item ref="fujiandanwei" prop="fujiandanwei" :label="danwei" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }">
					<a-input v-model="form.fujiandanwei" :placeholder="danwei"  @blur="() => {$refs.fujiandanwei.onFieldBlur();}"/>
				</a-form-model-item>
                <a-form-model-item ref="fujiantime" prop="fujiantime" :label="shijian" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }">
                    <a-date-picker type="date" v-model="form.fujiantime" suffix-icon=" " @change="onchangetime" :placeholder="shijian"/>
				</a-form-model-item>
				<a-form-model-item ref="fujianfile" prop="fujianfile" label="上传文件（50M以内，pdf格式）：" align="left" :label-col="{ span:12 }" :wrapper-col="{ span: 8}">
					<!-- <a-input v-model="form.fujianfile" accept=".pdf" @change="handleUpload" type="file"/> -->
                    <a-upload
                        action="#"
                        accept='.pdf'
                        :file-list="fileList"
                        :show-upload-list="showUploadList"
                        :before-upload="beforeUpload"
                    >
                        <a-button style="width: 120px;height: 40px;line-height: 40px;margin:0;background:#fff;color:#333;"><a-icon type="upload" />上传</a-button>
                    </a-upload>
				</a-form-model-item>
			</a-form-model>
		</a-modal>
        <a-modal
			:title="modal_title"
            class="enclosure_modal"
			:visible="visible_edit"
            :maskClosable="false"
            :width="500"
            @cancel="handleCancel_edit"
		>
            <template slot="footer">
                <a-button @click="handleCancel_edit">取消</a-button>
                <a-button key="submit" type="primary" :disabled="disabled_edit" @click="handleSubmit_edit">保存</a-button>
            </template>
			<a-form-model ref="ruleForm_edit" :model="form_edit" :rules="rules_edit" >
				<!-- <a-form-model-item ref="fujianname_edit" prop="fujianname_edit" label="附件名称：" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }">
					<a-input v-model="form_edit.fujianname_edit" placeholder="附件名称"  @blur="() => {$refs.fujianname_edit.onFieldBlur();}"/>
				</a-form-model-item> -->
                <a-form-model-item ref="fujiandanwei_edit" prop="fujiandanwei_edit" :label="danwei" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }">
					<a-input v-model="form_edit.fujiandanwei_edit" :placeholder="danwei"  @blur="() => {$refs.fujiandanwei_edit.onFieldBlur();}"/>
				</a-form-model-item>
                <a-form-model-item ref="fujiantime_edit" prop="fujiantime_edit" :label="shijian" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }">
                    <a-date-picker type="date" v-model="form_edit.fujiantime_edit" suffix-icon=" " @change="onchangetime_edit" :placeholder="shijian"/>
				</a-form-model-item>
				<a-form-model-item ref="fujianfile_edit" prop="fujianfile_edit" label="上传文件（50M以内，pdf格式）：" :label-col="{ span:12 }" :wrapper-col="{ span: 8 }">
					<!-- <a-input v-model="form_edit.fujianfile_edit" accept=".pdf" @change="handleUpload" type="file"/> -->
				    <a-upload
                        action="#"
                        accept='.pdf'
                        :file-list="fileList"
                        :show-upload-list="showUploadList"
                        :before-upload="beforeUpload"
                    >
                        <a-button style="width: 120px;height: 40px;line-height: 40px;margin:0;background:#fff;color:#333;"><a-icon type="upload" />重新上传</a-button>
                    </a-upload>
                </a-form-model-item>
                <a-form-model-item label="已上传文件：" :label-col="{ span:5 }" :wrapper-col="{ span: 17 }">
					<a-input v-model="form_edit.fujianrename_edit" disabled />
				</a-form-model-item>
			</a-form-model>
		</a-modal>
        <!-- <div class="showpdf" v-if="showpdf">
            <img class="closebtn pointer" @click="closepdf" src="@/assets/img/close1.png"/>
            <testPdf :cxj_cxj_id="cxj_cxj_id" :file-path="filePath"></testPdf>
        </div> -->
        <testPdf :cxj_cxj_id="cxj_cxj_id" :file-path="filePath" :showPdf="showpdf"></testPdf>
    </div>
</template>

<script>
import {
    cxjsb_jdpsAdd,
    cxjsb_getJdps,
    cxjsb_jdzmList,
    cxjsb_jdpsDelete,
    cxjsb_getPszm,
    cxjsb_pszmAdd,
    cxjsb_pszmList,
    cxjsb_pszmDelete,
    cxjsb_getYsbg,
    cxjsb_ysbgAdd,
    cxjsb_ysbgList,
    cxjsb_ysbgDelete,
    cxjsb_getPjzm,
    cxjsb_pjzmAdd,
    cxjsb_pjzmList,
    cxjsb_pjzmDelete,
    cxjsb_getCxbg,
    cxjsb_cxbgAdd,
    cxjsb_cxbgList,
    cxjsb_cxbgDelete,
    cxjsb_getQtzm,
    cxjsb_qtzmAdd,
    cxjsb_qtzmList,
    cxjsb_qtzmDelete
} from '@/api/shenbao';
import testPdf from '@/views/declarationSystem/declare/testPdf';
import { mapActions } from 'vuex'
export default {
    name: 'Certificate',
    props: ['is_modify'],
    components: {
        testPdf
    },
    data() {
        return {
            modal_title: '',
            visible: false,
            visible_edit: false,
            confirmLoading: false,
            // form: this.$form.createForm(this, { name: 'coordinated' }),
            cxj_cxj_id: '',
            form: {
                // fujianname: '',
                fujiandanwei: '',
                fujiantime: null,
                fujianfile: ''
            },
            rules: {
                // fujianname: [
                //     { required: true, message: '请填写附件名称',trigger: 'blur' }
                // ],
                fujiandanwei: [
                    { required: true, message: '请填写单位名称',trigger: 'blur' }
                ],
                fujiantime: [{required: true, message: '请选择时间',trigger: 'change'}],
                fujianfile: [{ required: true, message: '请上传文件',trigger: 'change' }],
            },
            form_edit: {
                // fujianname_edit: '',
                fujiandanwei_edit: '',
                fujiantime_edit: null,
                fujianfile_edit: '',
                fujianrename_edit: '',
            },
            rules_edit: {
                // fujianname_edit: [
                //     { required: true, message: '请填写附件名称',trigger: 'blur' }
                // ],
                fujiandanwei_edit: [
                    { required: true, message: '请填写单位名称',trigger: 'blur' }
                ],
                fujiantime_edit: [{required: true, message: '请选择时间',trigger: 'change'}],
                fujianfile_edit: [],
            },
            files: '',
            files_edit: '',
            upload_type: '',
            jdzmlist: [],
            pszmlist: [],
            ysbglist: [],
            pjzmlist: [],
            cxbglist: [],
            qtzmlist: [],
            edit_id: '',
            fileList: [],
            showUploadList: {
                showDownloadIcon: false,
                showRemoveIcon: false,
            },
            disabled_add: false,
            disabled_edit: false,
            danwei: '',
            shijian: '',
            showpdf: false,
            filePath: '',
        }
    },
    methods: {
        ...mapActions('fillingSteps', ['getStatus']),
        handleCancel() {
            this.visible = false;
            this.disabled_add = false;
            this.files = '';
            this.resetForm();
        },
        handleCancel_edit() {
            this.visible_edit = false;
            this.disabled_edit = false;
            this.files_edit = '';
            this.resetForm_edit();
        },
        upload_jdzm() {
            this.modal_title = '鉴定证书';
            this.edit_id = '';
            this.upload_type = 0;
            this.visible = true;
            this.files = '';
            this.danwei = '鉴定单位';
            this.shijian = '鉴定时间';
        },
        // closepdf() {
        //     this.filePath = '';
        //     this.showpdf = false;
        // },
        preview_jdzm(filePath) {
            // this.showpdf = true;
            this.showpdf = !this.showpdf;
            this.filePath = filePath;
            // let that = this;
            // let routeData = this.$router.resolve({
            //     path: '/shenbao/pdfFile',
            //     query: {
            //         cxj_cxj_id: that.cxj_cxj_id,
            //         path: filePath
            //     }
            // });
            // window.open(routeData.href, '_blank');
        },
        edit_jdzm(id) {
            this.modal_title = '鉴定证书';
            this.upload_type = 0;
            this.visible_edit = true;
            this.files = '';
            this.edit_id = id;
            let that = this;
            this.danwei = '鉴定单位';
            this.shijian = '鉴定时间';
            cxjsb_getJdps({cxj_cxj_id:that.cxj_cxj_id,id}).then(res=>{
                if (res.data.code=='200') {
                    let data = res.data.result;
                    // this.form_edit.fujianname_edit = data.fileName;
                    this.form_edit.fujiandanwei_edit = data.jdzsDwmc;
                    console.log(this.form_edit.fujianname_edit, 'this.form_edit.fujianname_edi')
                    this.form_edit.fujiantime_edit = data.jdzsSj;
                    this.form_edit.fujianrename_edit = data.fileRename;
                    // this.form.fujianfile = that.getObjectURL(data.filePath);
                }
                console.log(res, 'res')
            })
        },
        del_jdzm(id) {
            let that = this;
            this.$confirm({
                content: '确定要删除该项吗？',
                onOk() {
                    cxjsb_jdpsDelete({
                        cxj_cxj_id: that.cxj_cxj_id,
                        id: id
                    }).then(res=>{
                        let data = res.data;
                        if (data.success) {
                            that.$message.success('删除成功');
                            that.get_cxjsb_jdzmList();
                        } else {
                            that.$message.error(data.message);
                        }
                    })
                },
                cancelText: '取消',
                onCancel() {
                    that.destroyAll();
                },
            });
        },
        upload_pszs() {
            this.modal_title = '评审证书';
            this.upload_type = 1;
            this.visible = true;
            this.files = '';
            this.danwei = '评审单位';
            this.shijian = '评审时间';
        },
        preview_pszs(filePath) {
            // this.showpdf = true;
            this.showpdf = !this.showpdf;
            this.filePath = filePath;
            // let that = this;
            // let routeData = this.$router.resolve({
            //     path: '/shenbao/pdfFile',
            //     query: {
            //         cxj_cxj_id: that.cxj_cxj_id,
            //         path: filePath
            //     }
            // });
            // window.open(routeData.href, '_blank');
        },
        edit_pszs(id) { //
            this.modal_title = '评审证书';
            this.upload_type = 1;
            this.visible_edit = true;
            this.files = '';
            this.edit_id = id;
            this.danwei = '评审单位';
            this.shijian = '评审时间';
            let that = this;
            cxjsb_getPszm({cxj_cxj_id:that.cxj_cxj_id,id}).then(res=>{
                if (res.data.code=='200') {
                    let data = res.data.result;
                    // this.form_edit.fujianname_edit = data.fileName;
                    this.form_edit.fujiandanwei_edit = data.pszmDwmc;
                    this.form_edit.fujiantime_edit = data.pszmSj;
                    this.form_edit.fujianrename_edit = data.fileRename;
                    // this.form.fujianfile = that.getObjectURL(data.filePath);
                }
                console.log(res, 'res')
            })
        },
        del_pszs(id) {
            let that = this;
            this.$confirm({
                content: '确定要删除该项吗？',
                onOk() {
                    cxjsb_pszmDelete({
                        cxj_cxj_id: that.cxj_cxj_id,
                        id: id
                    }).then(res=>{
                        let data = res.data;
                        if (data.success) {
                            that.$message.success('删除成功');
                            that.get_cxjsb_pszmList();
                        } else {
                            that.$message.error(data.message);
                        }
                    })
                },
                cancelText: '取消',
                onCancel() {
                    that.destroyAll();
                },
            });
        },
        upload_ysbg() {
            this.modal_title = '验收报告';
            this.upload_type = 2;
            this.visible = true;
            this.files = '';
            this.danwei = '验收单位';
            this.shijian = '验收时间';
        },
        preview_ysbg(filePath) {
            // this.showpdf = true;
            this.showpdf = !this.showpdf;
            this.filePath = filePath;
            // let that = this;
            // let routeData = this.$router.resolve({
            //     path: '/shenbao/pdfFile',
            //     query: {
            //         cxj_cxj_id: that.cxj_cxj_id,
            //         path: filePath
            //     }
            // });
            // window.open(routeData.href, '_blank');
        },
        edit_ysbg(id) {
            this.modal_title = '验收报告';
            this.upload_type = 2;
            this.visible_edit = true;
            this.files = '';
            this.edit_id = id;
            this.danwei = '验收单位';
            this.shijian = '验收时间';
            let that = this;
            cxjsb_getYsbg({cxj_cxj_id:that.cxj_cxj_id,id}).then(res=>{
                if (res.data.code=='200') {
                    let data = res.data.result;
                    // this.form_edit.fujianname_edit = data.fileName;
                    this.form_edit.fujiandanwei_edit = data.ysbgDwmc;
                    this.form_edit.fujiantime_edit = data.ysbgSj;
                    this.form_edit.fujianrename_edit = data.fileRename;
                    // this.form.fujianfile = that.getObjectURL(data.filePath);
                }
                console.log(res, 'res')
            })
        },
        del_ysbg(id) {
            let that = this;
            this.$confirm({
                content: '确定要删除该项吗？',
                onOk() {
                    let formData = new FormData();
                    formData.append('cxj_cxj_id', that.cxj_cxj_id)
                    formData.append('id', id)
                    cxjsb_ysbgDelete({
                        cxj_cxj_id: that.cxj_cxj_id,
                        id: id
                    }).then(res=>{
                        let data = res.data;
                        if (data.success) {
                            that.$message.success('删除成功');
                            that.get_cxjsb_ysbgList();
                        } else {
                            that.$message.error(data.message);
                        }
                    })
                },
                cancelText: '取消',
                onCancel() {
                    that.destroyAll();
                },
            });
        },
        upload_pjzm() {
            this.modal_title = '评价证书';
            this.upload_type = 3;
            this.visible = true;
            this.files = '';
            this.danwei = '评价单位';
            this.shijian = '评价时间';
        },
        preview_pjzm(filePath) {
            // this.showpdf = true;
            this.showpdf = !this.showpdf;
            this.filePath = filePath;
            // let that = this;
            // let routeData = this.$router.resolve({
            //     path: '/shenbao/pdfFile',
            //     query: {
            //         cxj_cxj_id: that.cxj_cxj_id,
            //         path: filePath
            //     }
            // });
            // window.open(routeData.href, '_blank');
        },
        edit_pjzm(id) {
            this.modal_title = '评价证书';
            this.upload_type = 3;
            this.visible_edit = true;
            this.files = '';
            this.edit_id = id;
            this.danwei = '评价单位';
            this.shijian = '评价时间';
            let that = this;
            cxjsb_getPjzm({cxj_cxj_id:that.cxj_cxj_id,id}).then(res=>{
                if (res.data.code=='200') {
                    let data = res.data.result;
                    // this.form_edit.fujianname_edit = data.fileName;
                    this.form_edit.fujiandanwei_edit = data.pjzmDwmc;
                    this.form_edit.fujiantime_edit = data.pjzmSj;
                    this.form_edit.fujianrename_edit = data.fileRename;
                    // this.form.fujianfile = that.getObjectURL(data.filePath);
                }
                console.log(res, 'res')
            })
        },
        del_pjzm(id) {
            let that = this;
            this.$confirm({
                content: '确定要删除该项吗？',
                onOk() {
                    let formData = new FormData();
                    formData.append('cxj_cxj_id', that.cxj_cxj_id)
                    formData.append('id', id)
                    cxjsb_pjzmDelete({
                        cxj_cxj_id: that.cxj_cxj_id,
                        id: id
                    }).then(res=>{
                        let data = res.data;
                        if (data.success) {
                            that.$message.success('删除成功');
                            that.get_cxjsb_pjzmList();
                        } else {
                            that.$message.error(data.message);
                        }
                    })
                },
                cancelText: '取消',
                onCancel() {
                    that.destroyAll();
                },
            });
        },
      upload_cxbg() {
        this.modal_title = '查新报告';
        this.upload_type = 4;
        this.visible = true;
        this.files = '';
        this.danwei = '查新单位';
        this.shijian = '查新时间';
      },
      preview_cxbg(filePath) {
        // this.showpdf = true;
        this.showpdf = !this.showpdf;
        this.filePath = filePath;
        // let that = this;
        // let routeData = this.$router.resolve({
        //     path: '/shenbao/pdfFile',
        //     query: {
        //         cxj_cxj_id: that.cxj_cxj_id,
        //         path: filePath
        //     }
        // });
        // window.open(routeData.href, '_blank');
      },
      edit_cxbg(id) {
        this.modal_title = '查新报告';
        this.upload_type = 4;
        this.visible_edit = true;
        this.files = '';
        this.edit_id = id;
        this.danwei = '查新单位';
        this.shijian = '查新时间';
        let that = this;
        cxjsb_getCxbg({cxj_cxj_id:that.cxj_cxj_id,id}).then(res=>{
          if (res.data.code=='200') {
            let data = res.data.result;
            // this.form_edit.fujianname_edit = data.fileName;
            this.form_edit.fujiandanwei_edit = data.cxbgDwmc;
            this.form_edit.fujiantime_edit = data.cxbgSj;
            this.form_edit.fujianrename_edit = data.fileRename;
            // this.form.fujianfile = that.getObjectURL(data.filePath);
          }
          console.log(res, 'res')
        })
      },
      del_cxbg(id) {
        let that = this;
        this.$confirm({
          content: '确定要删除该项吗？',
          onOk() {
            let formData = new FormData();
            formData.append('cxj_cxj_id', that.cxj_cxj_id)
            formData.append('id', id)
            cxjsb_cxbgDelete({
              cxj_cxj_id: that.cxj_cxj_id,
              id: id
            }).then(res=>{
              let data = res.data;
              if (data.success) {
                that.$message.success('删除成功');
                that.get_cxjsb_cxbgList();
              } else {
                that.$message.error(data.message);
              }
            })
          },
          cancelText: '取消',
          onCancel() {
            that.destroyAll();
          },
        });
      },
      upload_qtzm() {
        this.modal_title = '其他证明';
        this.upload_type = 5;
        this.visible = true;
        this.files = '';
        this.danwei = '评价单位';
        this.shijian = '评价时间';
      },
      preview_qtzm(filePath) {
        // this.showpdf = true;
        this.showpdf = !this.showpdf;
        this.filePath = filePath;
        // let that = this;
        // let routeData = this.$router.resolve({
        //     path: '/shenbao/pdfFile',
        //     query: {
        //         cxj_cxj_id: that.cxj_cxj_id,
        //         path: filePath
        //     }
        // });
        // window.open(routeData.href, '_blank');
      },
      edit_qtzm(id) {
        this.modal_title = '其他证明';
        this.upload_type = 5;
        this.visible_edit = true;
        this.files = '';
        this.edit_id = id;
        this.danwei = '评价单位';
        this.shijian = '评价时间';
        let that = this;
        cxjsb_getQtzm({cxj_cxj_id:that.cxj_cxj_id,id}).then(res=>{
          if (res.data.code=='200') {
            let data = res.data.result;
            // this.form_edit.fujianname_edit = data.fileName;
            this.form_edit.fujiandanwei_edit = data.qtzmDwmc;
            this.form_edit.fujiantime_edit = data.qtzmSj;
            this.form_edit.fujianrename_edit = data.fileRename;
            // this.form.fujianfile = that.getObjectURL(data.filePath);
          }
          console.log(res, 'res')
        })
      },
      del_qtzm(id) {
        let that = this;
        this.$confirm({
          content: '确定要删除该项吗？',
          onOk() {
            let formData = new FormData();
            formData.append('cxj_cxj_id', that.cxj_cxj_id)
            formData.append('id', id)
            cxjsb_qtzmDelete({
              cxj_cxj_id: that.cxj_cxj_id,
              id: id
            }).then(res=>{
              let data = res.data;
              if (data.success) {
                that.$message.success('删除成功');
                that.get_cxjsb_qtzmList();
              } else {
                that.$message.error(data.message);
              }
            })
          },
          cancelText: '取消',
          onCancel() {
            that.destroyAll();
          },
        });
      },
        resetForm() {
            this.edit_id = '';
            this.$nextTick(()=>{
                this.$refs.ruleForm.resetFields();
                this.fileList = [];
            })
        },
        resetForm_edit() {
            this.edit_id = '';
            this.$nextTick(()=>{
                this.$refs.ruleForm_edit.resetFields();
                this.fileList = [];
            })
        },
        onchangetime(date, dateString) {
            this.form.fujiantime = dateString;
        },
        onchangetime_edit(date, dateString) {
            this.form_edit.fujiantime_edit = dateString;
        },
        beforeUpload(file) {
            if (file) {
                if (file.size > 50*1024*1024) { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                    this.$message.warning('文件最大为50兆')
                    return
                } else if (file.type!='application/pdf') { // 此处判断上传文件的格式
                  this.$message.warning('请上传pdf格式的文件')
                  return
                } else {
                    this.files = file;
                    this.form.fujianfile = file;
                    this.fileList = [file];
                    console.log(this.fileList)
                }
            }
            return false;
        },
        handleUpload(e) {
            const files = e.target.files[0];
            if (files) {
                this.files = files;
            }
        },
        handleSubmit() {
            let that = this;
            this.disabled_add = true;
            this.$refs.ruleForm.validate(valid => {
                if (valid) {
                    let formData = new FormData();
                    formData.append('cxj_cxj_id', that.cxj_cxj_id);
                    formData.append('dwmc', this.form.fujiandanwei);
                    formData.append('zmsj', this.form.fujiantime);
                    formData.append('file', this.files);
                    formData.append('id', '');
                    that.getData(formData);
                } else {
                    return false;
                }
            });
        },
        handleSubmit_edit() {
            let that = this;
            this.disabled_edit = true;
            this.$refs.ruleForm_edit.validate(valid => {
                if (valid) {
                    let formData = new FormData();
                    formData.append('cxj_cxj_id', that.cxj_cxj_id);
                    formData.append('dwmc', this.form_edit.fujiandanwei_edit);
                    formData.append('zmsj', this.form_edit.fujiantime_edit);
                    if (this.files) {
                        formData.append('file', this.files);
                    }
                    formData.append('id', this.edit_id);
                    that.getData(formData);
                } else {
                    return false;
                }
            });
        },
        getData(formData) {
            let that = this;
            if (that.upload_type == '0') {
                cxjsb_jdpsAdd(formData).then(res=>{
                    if (this.edit_id) {
                        this.handleCancel_edit();
                    } else {
                        this.handleCancel();
                    }
                    if (res.data.code=='200') {
                        that.getStatus(that.cxj_cxj_id)
                        that.$message.success('保存成功');
                        that.get_cxjsb_jdzmList();
                    } else {
                        that.$message.error(res.data.message);
                    }
                }).catch(err=>{
                    this.disabled_add = false;
                    this.disabled_edit = false;
                })
            } else if (that.upload_type == '1') {
                cxjsb_pszmAdd(formData).then(res=>{
                    if (this.edit_id) {
                        this.handleCancel_edit();
                    } else {
                        this.handleCancel();
                    }
                    if (res.data.code=='200') {
                        that.$message.success('保存成功');
                        that.get_cxjsb_pszmList();
                    } else {
                        that.$message.error(res.data.message);
                    }
                }).catch(err=>{
                    this.disabled_add = false;
                    this.disabled_edit = false;
                })
            } else if (that.upload_type == '2') {
                cxjsb_ysbgAdd(formData).then(res=>{
                    if (this.edit_id) {
                        this.handleCancel_edit();
                    } else {
                        this.handleCancel();
                    }
                    if (res.data.code=='200') {
                        that.getStatus(that.cxj_cxj_id)
                        that.$message.success('保存成功');
                        that.get_cxjsb_ysbgList();
                    } else {
                        that.$message.error(res.data.message);
                    }
                }).catch(err=>{
                    this.disabled_add = false;
                    this.disabled_edit = false;
                })
            } else if (that.upload_type == '3') {
                cxjsb_pjzmAdd(formData).then(res=>{
                    if (this.edit_id) {
                        this.handleCancel_edit();
                    } else {
                        this.handleCancel();
                    }
                    if (res.data.code=='200') {
                        that.getStatus(that.cxj_cxj_id)
                        that.$message.success('保存成功');
                        that.get_cxjsb_pjzmList();
                    } else {
                        that.$message.error(res.data.message);
                    }
                }).catch(err=>{
                    this.disabled_add = false;
                    this.disabled_edit = false;
                })
            } else if (that.upload_type == '4') {
              cxjsb_cxbgAdd(formData).then(res=>{
                if (this.edit_id) {
                  this.handleCancel_edit();
                } else {
                  this.handleCancel();
                }
                if (res.data.code=='200') {
                    that.getStatus(that.cxj_cxj_id)
                    that.$message.success('保存成功');
                    that.get_cxjsb_cxbgList();
                } else {
                  that.$message.error(res.data.message);
                }
              }).catch(err=>{
                this.disabled_add = false;
                this.disabled_edit = false;
              })
            } else if (that.upload_type == '5') {
              cxjsb_qtzmAdd(formData).then(res=>{
                if (this.edit_id) {
                  this.handleCancel_edit();
                } else {
                  this.handleCancel();
                }
                if (res.data.code=='200') {
                    that.getStatus(that.cxj_cxj_id)
                    that.$message.success('保存成功');
                    that.get_cxjsb_qtzmList();
                } else {
                  that.$message.error(res.data.message);
                }
              }).catch(err=>{
                this.disabled_add = false;
                this.disabled_edit = false;
              })
            }
        },
        get_cxjsb_jdzmList() {
            let that = this;
            cxjsb_jdzmList({cxj_cxj_id: that.cxj_cxj_id}).then(res=>{
                if (res.data.code=='200') {
                    that.jdzmlist = res.data.result;
                }
            })
        },
        get_cxjsb_pszmList() {
            let that = this;
            cxjsb_pszmList({cxj_cxj_id: that.cxj_cxj_id}).then(res=>{
                if (res.data.code=='200') {
                    that.pszmlist = res.data.result;
                }
            })
        },
        get_cxjsb_ysbgList() {
            let that = this;
            cxjsb_ysbgList({cxj_cxj_id: that.cxj_cxj_id}).then(res=>{
                if (res.data.code=='200') {
                    that.ysbglist = res.data.result;
                }
            })
        },
        get_cxjsb_pjzmList() {
            let that = this;
            cxjsb_pjzmList({cxj_cxj_id: that.cxj_cxj_id}).then(res=>{
                if (res.data.code=='200') {
                    that.pjzmlist = res.data.result;
                }
            })
        },
        get_cxjsb_cxbgList() {
          let that = this;
          cxjsb_cxbgList({cxj_cxj_id: that.cxj_cxj_id}).then(res=>{
            if (res.data.code=='200') {
              that.cxbglist = res.data.result;
            }
          })
        },
        get_cxjsb_qtzmList() {
          let that = this;
          cxjsb_qtzmList({cxj_cxj_id: that.cxj_cxj_id}).then(res=>{
            if (res.data.code=='200') {
              that.qtzmlist = res.data.result;
            }
          })
        },
        destroyAll() {
            this.$destroyAll();
        },
        init() {
            this.get_cxjsb_jdzmList();
            this.get_cxjsb_pszmList();
            this.get_cxjsb_ysbgList();
            this.get_cxjsb_pjzmList();
            this.get_cxjsb_cxbgList();
            this.get_cxjsb_qtzmList();
        },
    },
    mounted() {
        this.cxj_cxj_id = this.$route.query.cxj_cxj_id;
        this.init();
    }
}
</script>

<style lang="less" scoped>
.list_title {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    margin-bottom: 25px;
    .list_name {
        font-size: 16px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #3388EE;
    }
}
.shangchuan {
    width: 70px;
    height: 32px;
    line-height: 32px;
    color:#fff;
    text-align: center;
    border: 1px solid #3388EE;
    background: #3388EE;
    margin-left: 10px;
    border-radius: 4px;
    display: inline-block;
}
.tableList {
    // padding-bottom: 30px;
    // border-bottom: 1px solid #EEEEEE;
    table {
        margin-top: 20px;
        background: #FFFFFF;
        thead {
            background: #F5F5F5;
            tr {
                th {
                    height: 60px;
                    font-size: 16px;
                    font-family: PingFangSC-Medium, PingFang SC;
                    font-weight: 500;
                    color: #333333;
                }
            }
        }
        tbody {
            tr {
                height: 52px;
                border-bottom: 1px solid #E8E8E8;
                td {
                    color: #444444;
                    font-size: 14px;
                    font-weight: 400;
                    height: 52px;
                }
            }
        }
    }
}
</style>
